package com.zoop.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {

	@Value("${server.port}")
	private String port;
	
	@RequestMapping(value="map")
	public String map() {
		return "/map";
	}
	
	@RequestMapping(value="/mine")
	public String mine(Model model) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", "8081-1");
		map.put("name", "8081");
		map.put("birthday", "8081");
		map.put("salary", "8081");
		Map<String, Object> map1 = new HashMap<String, Object>();
		map1.put("id", "22");
		map1.put("name", "2jj1");
		map1.put("birthday", "22");
		map1.put("salary", "jj22j");
		list.add(map);
		list.add(map1);
		model.addAttribute("list",list);
		model.addAttribute("hello","jihihuhi");
		return "/mine";
	}
	
	//首页
	@RequestMapping(value="/index")
	public String index(Model model) {
		return "/index";
	}
	
	//商家列表
	@RequestMapping(value="/shopList")
	public String shopList(Model model, HttpServletRequest request) {
		String storeName = request.getParameter("store_name");
		if(storeName != null && storeName.equals("1")) {
			List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("id", "11");
			map.put("name", "1jj1");
			list.add(map);
			model.addAttribute("list", list);
		}
		return "/html/shopList";
	}
	
	//开店申请
	@RequestMapping(value="/apply_list")
	public String applyList(Model model) {
		return "/html/apply_list";
	}
	
	@RequestMapping(value="/exec")
	@ResponseBody
	public String exec() {
		return port;
	}
	
}
